How do I make a dialog box? [on hold]

Posted by bill on Game Development See other posts from Game Development or by bill
Published on 2013-10-22T21:25:29Z Indexed on 2013/10/22 22:03 UTC
Read the original article Hit count: 189

Filed under:
|

By dialog box I mean when player talks to someone, a box shows up with text on it.

I haven't found much about this topic online, so I created a basic dialog box:

//in dialog box i have only two methods 
public void createBox(int x, int y, int width, int height, String txt) {
    this.x = x;
    this.y = y;
    this.width = width;
    this.height = height;
    this.txt = txt;
}

//draw dialog box
public void draw(Graphics2D g) {
    if (txt != null) {
        g.setColor(Color.red);
        g.drawRect(x,y,width,height);
        g.setColor(Color.black);
        g.fillRect(x, y, width, height);
        g.setColor(Color.white);
        g.drawString(txt, x + 10, y + 10);
    }
}

I wanted to now can I make this better?

© Game Development or respective owner

Related posts about java

Related posts about gui